<template>
  <div style="width: 100%;height: 100%;box-sizing: border-box;padding-left: 10px;">
    <div v-if="statusinfo == '待审核'">你的信息已提交，请您耐心等待</div>
    <div v-if="statusinfo == '未通过'">您的实名认证未通过,请您重新认证</div>
    <div>
      <table border="0">
        <tr>
          <td style="width: 80px;">姓名：</td>
          <td><input type="text" v-model="form.real_name" style="border: 1px solid;" /></td>
        </tr>
        <tr>
          <td style="width: 80px;">身份证号：</td>
          <td><input type="text" v-model="form.code" style="border: 1px solid;" /></td>
        </tr>
        <tr>
          <td style="width: 80px;">银行卡号：</td>
          <td><input type="number" v-model="form.bank_code" style="border: 1px solid;" /></td>
        </tr>
        <tr>
          <td style="width: 80px;">开户银行：</td>
          <td><input type="text" v-model="form.bank_name" style="border: 1px solid;" /></td>
        </tr>
        <tr>
          <td style="width: 80px;">开户支行：</td>
          <td><input type="text" v-model="form.child_name" style="border: 1px solid;" /></td>
        </tr>
      </table>

      <button v-if="status" @click="btnlist && sub()" style="padding:2px 15px;text-align: center;margin-top: 20px;border: 1px solid;">上传认证</button>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      form: {
        real_name: '',
        code: '',
        bank_name: '',
        bank_code: '',
        child_name: ''
      },
      param: {}, //信息
      btnlist: true, //防止多次点击
      status: true, //提交按钮显示
      statusinfo: null // 判断通过状态
    };
  },
  mounted() {
    this.authentication();
  },
  methods: {
    //认证
    sub() {
      this.btnlist = false;
      if (this.form.real_name == '') {
        this.btnlist = true;
        this.$notify.error('请输入您的姓名！');
        return;
      }
      if (this.form.code == '') {
        this.btnlist = true;
        this.$notify.error('请输入您的身份证号！');
        return;
      }
      if (this.form.bank_name == '') {
        this.btnlist = true;
        this.$notify.error('请输入您的开户行！');
        return;
      }
      if (this.form.bank_code == '') {
        this.btnlist = true;
        this.$notify.error('请输入您的银行卡号！');
        return;
      }
      if (this.form.child_name == '') {
        this.btnlist = true;
        this.$notify.error('请输入您的银行卡号！');
        return;
      }
      this.$post('addons/tf-futures/member/upload', this.form).then(res => {
        this.btnlist = true;
        if (res.code == 200) {
          this.$notify.success('提交成功！请耐心等待后台审核');
          this.authentication();
          this.form.real_name = '';
          this.form.code = '';
          this.form.bank_name = '';
          this.form.bank_code = '';
          this.form.child_name = '';
        } else {
          this.$notify.error(res.message.code || '提交失败！');
        }
      });
    },
    //获取认证信息
    authentication() {
      this.$get('addons/tf-futures/member/identity-status').then(res => {
        if (res.code == 200) {
          this.statusinfo = res.data.status;
          this.form.real_name = res.data.real_name;
          this.form.code = res.data.code;
          this.form.bank_name = res.data.bank_name;
          this.form.bank_code = res.data.bank_code;
          this.form.child_name = res.data.child_name;
          if (res.data.status == '未通过') {
            this.status = true;
          }else{
            this.status = false;
          }
        } else {
          this.statusinfo = null;
          this.status = true;
        }
      });
    }
  }
};
</script>

<style scoped lang="less"></style>
